<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.crm.util.ApplicationContext"%>
<%@page import="com.crm.entity.Business,com.crm.util.Constants"%>
<%@page import="com.crm.entity.Executives"%>
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/temp.dwt" codeOutsideHTMLIsLocked="false" -->
<%@page import="com.crm.entity.Clientdet"%>
<%@page language="java" import="java.sql.*,java.util.*"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<%=application.getContextPath()%>/css/jquery-ui-1.8.17.custom.css"/>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script> 
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.17.custom.min.js"></script> 
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>	
<script language="JavaScript" src="<%=application.getContextPath()%>/js/gen_validatorv4.js" type="text/javascript" ></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/colResizable-1.3.min.js"></script>	
<style >
.ui-dialog {
	
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	}
		
</style>
<script type="text/javascript">
$(function(){
		<%
		if(request.getAttribute("xlfile")!=null){%>
				$("#userTable").html("<%=request.getAttribute("xlfile")%>");
		<%}%>
	  $("#userTable").colResizable();
	});
function autoComplete(i,ID) {
	var rowCount=$("#rowcount").val();
	var availTags=new Array();
	if(rowCount!=0 && rowCount!=1){
	for(i=1;i<rowCount;i++){
		availTags.push($("#"+ID+""+i).val());
	}}
    	$("input#"+ID+""+i).autocomplete({
    		source:availTags
		});
    	 jQuery('.ui-autocomplete').css({'font-size':'8px','font-family':'Arial','max-height': '100px',
    		'overflow-y': 'scroll', 'padding-right': '20px', 'overflow-x': 'hidden'}); 
    		
  }
function orgAutoComplete() {
	var rowCount=$("#rowcount").val();
	var availTags=new Array();
	 <% List<Clientdet> lst=(List<Clientdet>)request.getAttribute("orgList"); %>
	<% 
    if(lst!=null){
	for(int i=0;i<lst.size();i++){ %>
  availTags.push("<%=lst.get(i).getOrganisation()%>");
         	<%	}
        	}%>
    	$("#org").autocomplete({
    		source:availTags
		});
    		
  }
        function addRow(userTable) {
 
            var table = document.getElementById(userTable);
 			var rowCount = table.rows.length;
			var row = table.insertRow(rowCount);
			
			table.setAttribute("bgColor", "#C5E4EB");
			 var cell0=row.insertCell(0);
			    cell0.setAttribute("bgColor","#FFFFFF");
			    cell0.innerHTML='<input type="checkbox" name="chkbox"/>';
			
		    var cell1 = row.insertCell(1);
		    cell1.innerHTML = rowCount ;
           	cell1.setAttribute("bgColor","#FFFFFF");
                      	
            var cell2 = row.insertCell(2);
            cell2.setAttribute("bgColor","#FFFFFF");
           
            var element2 = document.createElement("input");
			element2.type = "text";
			element2.name="partno"+rowCount;
			element2.id="partno"+rowCount;
			element2.className="part";
			cell2.appendChild(element2);
                                		
			
			var cell3=row.insertCell(3);
            cell3.setAttribute("bgColor","#FFFFFF");
            
            var element3 = document.createElement("input");
		element3.type = "text";
		element3.name="desc"+rowCount;
		element3.id="desc"+rowCount;
		element3.autocomplete="off";
		element3.setAttribute("onfocus","javascript:autoComplete("+rowCount+",'desc')");
		cell3.appendChild(element3);
		
		var cell4=row.insertCell(4);
        cell4.setAttribute("bgColor","#FFFFFF");
        
		 var element4 = document.createElement("input");
			element4.type = "text";
			element4.name="make"+rowCount;
			element4.id="make"+rowCount;
			element4.autocomplete="off";
			element4.setAttribute("onfocus","javascript:autoComplete("+rowCount+",'make')");
			cell4.appendChild(element4);	
			
			var cell5 = row.insertCell(5);
			cell5.setAttribute("bgColor","#FFFFFF");
			
			var element5 = document.createElement("input");
			element5.type = "text";
			element5.name="qty"+rowCount;
			element5.id="qty"+rowCount;
			cell5.appendChild(element5);	
			
			
			 
	            
	            
	            var cell6=row.insertCell(6);
	            cell6.setAttribute("bgColor","#FFFFFF");
				var element6 = document.createElement("input");
			element6.type = "text";
			element6.name="application"+rowCount;
			element6.id="application"+rowCount;
			element6.autocomplete="off";
			element6.setAttribute("onfocus","javascript:autoComplete("+rowCount+",'application')");
			cell6.appendChild(element6);
	            
	            var cell7=row.insertCell(7);
	            cell7.setAttribute("bgColor","#FFFFFF");
	            
	            var element7 = document.createElement("input");
			element7.type = "text";
			element7.name="specification"+rowCount;
			element7.autocomplete="off";
			element7.setAttribute("onfocus","javascript:autoComplete("+rowCount+",'specification')");
			element7.id="specification"+rowCount;
			cell7.appendChild(element7);
	            
	            $('#rowcount').val(rowCount);
	            $("#partno"+rowCount).focus();
        }
 
        function addRowData(rowin,userTable) {
        	 //jAlert(rowin);
            var table = document.getElementById(userTable);
 			var rowCount = table.rows.length;
			var row = table.insertRow(rowCount);
			
			table.setAttribute("bgColor", "#C5E4EB");
			 var cell0=row.insertCell(0);
			    cell0.setAttribute("bgColor","#FFFFFF");
			    cell0.innerHTML='<input type="checkbox" name="chkbox"/>';
			
		    var cell1 = row.insertCell(1);
		    cell1.innerHTML = rowCount ;
           	cell1.setAttribute("bgColor","#FFFFFF");
                      	
            var cell2 = row.insertCell(2);
            cell2.setAttribute("bgColor","#FFFFFF");
        	var val=document.getElementById("partno"+rowin);
            cell2.innerHTML='<input type="text" name="partno'+rowCount+'" value="'+val.value+'" id="partno'+rowCount+'"  />';
            
            
           
            /* var element2 = document.createElement("input");
			element2.type = "text";
		 */
			jAlert(val);
			
			/* element2.name="partno"+rowCount;
			element2.id="partno"+rowCount; */
			//cell2.appendChild(element2);
			
			  var cell3=row.insertCell(3);
            cell5.setAttribute("bgColor","#FFFFFF");
            
            var element3 = document.createElement("input");
		element3.type = "text";
		element3.name="desc"+rowCount;
		element3.id="desc"+rowCount;
		cell3.appendChild(element3);
		
		
			var cell4 = row.insertCell(4);
			 cell4.setAttribute("bgColor","#FFFFFF");
			
			 var element4 = document.createElement("input");
			element4.type = "text";
			element4.name="make"+rowCount;
			element4.id="make"+rowCount;
			cell4.appendChild(element4);	
			
                                		
			var cell5 = row.insertCell(5);
			cell5.setAttribute("bgColor","#FFFFFF");
			
			var element5 = document.createElement("input");
			element5.type = "text";
			element5.name="qty"+rowCount;
			element5.id="qty"+rowCount;
			cell5.appendChild(element5);	
			
	            
	            var cell6=row.insertCell(6);
	            cell6.setAttribute("bgColor","#FFFFFF");
	            
				var element6 = document.createElement("input");
			element6.type = "text";
			element6.name="application"+rowCount;
			element6.id="application"+rowCount;
			cell6.appendChild(element6);
	            
	            var cell7=row.insertCell(7);
	            cell7.setAttribute("bgColor","#FFFFFF");
	            
	            var element7 = document.createElement("input");
			element7.type = "text";
			element7.name="specification"+rowCount;
			element7.id="specification"+rowCount;
			cell7.appendChild(element7);
	            
	            $('#rowcount').val(rowCount);
        }
 
        function deleteRow(userTable) {
            var table = document.getElementById(userTable);
            var rowCount = table.rows.length;
            var al=true;
            
 		    for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                    al=false;
                }
            }
 		   if(al==true){
           	jAlert("Please Select Atleast One Row");
           }
			for(var i=0; i<rowCount-1; i++)
           table.rows[i+1].cells[1].innerHTML = i+1;
        }
        function AddSelRow(userTable) {
            try {
            var table = document.getElementById(userTable);
            var rowCount = table.rows.length;
 			
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                	//alert("the selected row  is called for chkbox "+chkbox);
                	addRowData(i,userTable);
                    /* table.deleteRow(i); */
                    table.
                    rowCount++;
                    i++;
                    //jAlert(rowCount);
                }
 
            }
			for(var i=0; i<rowCount-1; i++)

           table.rows[i+1].cells[1].innerHTML = i+1;
            }catch(e) {
                alert(e);
            }
        }
        
function getGroups(org){
	if(org==null || org=='' || org=='Please Select') return;
var orgn=org.value;
//alert(orgn);
var data="orgn="+orgn;

$.ajax({
	url:" <%=application.getContextPath()%>/newEnq/getGroups.do",
	mimetype: "text/plain",
	method: "post",
	data: data,
	cache:false,
	success: function(res){
		var e2=document.getElementById('groupId');
		$('#groupId')
	    .find('option')
	    .remove()
	    .end()
	   	;
		//alert(res);
		var o=document.createElement('option');
		o.value="Please Select";
		o.text="Please Select";
		e2.options.add(o);
		//alert(res);
		if(res.length!=0){
		var temp=res.split(",");
		
		if(temp != null){
			for(var i=0;i<temp.length;i++){
				var o=document.createElement('option');
				o.value=temp[i];
				o.text=temp[i];
				e2.options.add(o);
			}
		}
		}
	}

});

}

function getDivision(){
	var org=$("#org").val();
	if(org==null || org=='' || org=='Please Select') return;
var orgn=org;
//alert(orgn);
var data="orgn="+orgn;

$.ajax({
	url:" <%=application.getContextPath()%>/newEnq/getDiv.do",
	mimetype: "text/plain",
	method: "post",
	data: data,
	cache:false,
	success: function(res){
		var e2=document.getElementById('div');
		$('#div')
	    .find('option')
	    .remove()
	    .end()
	   	;
		//alert(res);
		var o=document.createElement('option');
		o.value="Please Select";
		o.text="Please Select";
		e2.options.add(o);
		if(res.length!=0){
		var temp=res.split(",");
		
		if(temp != null){
			for(var i=0;i<temp.length;i++){
				var o=document.createElement('option');
				o.value=temp[i];
				o.text=temp[i];
				e2.options.add(o);
			}
		}
		}
	}

});

}

function getUsers(group){
	if(group==null || group=='' || group=='Please Select') return;
	var divi=group.value;
	//alert(divi);
	 var org=$('#org').val();
	//lert(org);
	var data="division="+divi+"&org="+org;
$.ajax({
	url:" <%=application.getContextPath()%>/newEnq/getUsers.do",
	mimetype: "text/plain",
	method: "post",
	data: data,
	cache:false,
	success: function(res){
		var e2=document.getElementById('user');
		$('#user')
	    .find('option')
	    .remove()
	    .end()
	   	;
		//alert(res);
		var temp=res.split(",");
		var o=document.createElement('option');
		o.value="";
		o.text="Please Select";
		e2.options.add(o);
		if(temp != null){
			for(var i=0;i<temp.length-1;i++){
				var o=document.createElement('option');
				o.value=temp[i];
				o.text=temp[i];
				e2.options.add(o);
			}
		}
		
	}

});

}
</script>
<script type="text/javascript">
function getExec(comp){
var compny=comp.value;
//alert(orgn);

var data="company="+compny;

$.ajax({
	url:" <%=application.getContextPath()%>/newEnq/getExec.do",
	mimetype: "text/plain",
	method: "post",
	data: data,
	cache:false,
	success: function(res){
		var e2=document.getElementById('exeName');
		$('#exeName')
	    .find('option')
	    .remove()
	    .end()
	   	;
		//alert(res);
		var temp=res.split(",");
		var o=document.createElement('option');
		o.value="Please Select";
		o.text="Please Select";
		e2.options.add(o);
		if(temp != null){
			for(var i=0;i<temp.length-1;i++){
				var o=document.createElement('option');
				o.value=temp[i];
				o.text=temp[i];
				e2.options.add(o);
			}
		}
		
	}

});

}
</script>
<script type="text/javascript">
function xlValidate(){
	var val=$("#excel").val();
	if(val!= null && val!="" && val!=" "){
		return true;
	}else{
		alert("Please Select The XLS File To Upload");
		return false;
	}
}
function getEnqNo(enqType){
	var enqType=enqType.value;
	var org=$('#org').val();
	var divi=$('#groupId').val();

var data="org="+org+"&div="+divi+"&eType="+enqType;

$.ajax({
	url:" <%=application.getContextPath()%>/newEnq/getEnqNo.do",
	mimetype: "text/plain",
	method: "post",
	data: data,
	cache:false,
	success: function(res){
		
		$("#enqNum").val(res);
		
	}

});

}
</script>

<script>

	$(function() {
		$( "#datepicker" ).datepicker({ dateFormat: "dd-mm-yy" },"option", "autoSize", true);
	});
	</script>
	
	 <script type="text/javascript">
    $(document).ready(function(){
       $("#enqForm").validate({
    	   rules:{
    		   org: 
    			   "required",
    		   dDate: "required",
    		  /*  user: "required", */
    		  
    		   comp:"required",
    		 
    		   enqNum:"required",
    		   prob: {required: true, digits: true},
    		   eType:"required",
       
    		   div: "required",
    			   quotCurr: "required"
    	   },
       messages:{
    	   org: "Organisation must not be empty",
    	   dDate: "Due Date Must Not be empty",
    	   user: " User Name must not be Empty",
    	   div: "Division Must not Be empty",
    	   comp:"Company name must not be empty",
    	   opprName:"Opportunity Must not be empty",
    	   enqNum:"Enquiery Number must not be empty",
    	  prob:{
    		   required: "Probability must not be empty",
    		   digits: "Only Digits allowed for Probability"
    	   },
    	   projName:{
        	   required: "Telephone phone Number requred" 
           },
           eType:{
        	   required: "Enquiery Type Must requred"
           },
           quotCurr:"Currency must not be empty"
       }
       });
       });
    </script> 
    <script>
function open_new_window(url) {
	  window.open(url,"Printing Your Quotation","width=500,height=300,left=200,top=10");
	}
</script>
	
</head>

<body>

<div id="main" >
  <!-- <div id="header"></div> -->
   <%@ include file="common/header.jsp" %>
  <%@ include file="common/submenu.jsp" %>
  <div id="content">
   <div id="resultMsg" align="center" class="result_msg" >
    <% 
    	if(request.getParameter("refNo")!=null){
    		out.println(request.getParameter("refNo"));
    	}
    	
    %>
    </div> 
   <div id="Msg" align="center" class="result_msg" >
    <% 
    	if(request.getAttribute("msg")!=null){
    		out.println(request.getAttribute("msg"));
    	}
    	
    %>
    </div>
        <div class="boxIFS">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr><td align="left" width="50%">Instead Upload An Excel File  (As Of Now Only xls Files Are Allowed)</td>
          <td align="center" width="50%"><form method="post" action="<%=application.getContextPath()%>/newEnq/uploadExcel.do" enctype="multipart/form-data" onsubmit="javscript:return xlValidate();">
   	 <table><tr><td align="left" width="70%"><input type="file" name="excel"  class="form"  id="excel" accept="*.xls"/></td><td align="right" width="30%"><input type="submit" class="button" value="upload Excel file" /></td></tr>
   	 </table>
    </form> </td></tr>
    <tr><td>&nbsp;</td></tr>
     <tr><td>&nbsp;</td></tr>
    <tr><td>Please Follow The Same Format As This Excel File</td><td><a  class="linkclass" href="#"  onclick="open_new_window('<%=application.getContextPath() %>/newEnq/get_helpxls.do?attno=1')" >Open Sample Excel File</a></td></tr>
    </table>
    
      </div>
  <form action="<%= application.getContextPath()%>/newEnq/save.do" method="post" id="enqForm" name="enqForm">
    <div id="work-area2">
    
      <div class="heading2">New Enquiry </div>
	  
      <div class="boxIFS">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="3%">&nbsp;</td>
            <td width="95%"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td height="28">&nbsp;</td>
                <td align="left" valign="top">Organisation Name</td>
                <td align="left" valign="top"><input type="text" class="form" onfocus="javascript:orgAutoComplete();"  name="org"  id="org" onblur="javascript: getGroups(this)"/></td>
                <td align="left" valign="top">&nbsp; </td>
                <td align="left" valign="top">Group/Directorate</td>
                <td align="left" valign="top"><select name="group" id="groupId" class="form"  onblur="javascript: getUsers(this)">
                    <option value="">Please Select</option>
                </select></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">Name Of User </td>
                <td align="left" valign="top"><select name="user" id="user" class="form">
                    <option value="">Please Select</option>
                </select></td>
                <td>&nbsp;</td>
                <td align="left" valign="top">Enquiry Type </td>
                <td align="left" valign="top"><select name="eType" id="eType" class="form"  onblur="javascript: getEnqNo(this)">
                    <option value="">Please Select</option>
                    <option value="OPTS">Opportunity(OPTS)</option>
                    <option value="TE">Tender Enquiry(TE)</option>
                    <option value="CP">Cash Purchase(CP)</option>
                    <option value="BQ">Budgetary Quotation(BQ)</option>
                </select></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">Enquiry Number </td>
                <td align="left" valign="top"><input name="enqNum" id="enqNum" type="text" class="form" value=""/></td>
                <td>&nbsp;</td>
                <td align="left" valign="top">Bid Type </td>
                <td align="left" valign="top"><table width="70%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="19%"><label>
                        <input type="checkbox" name="techBid" value="technical Bid" />
                        </label>                      </td>
                      <td width="81%">Technical Bid </td>
                    </tr>
                    <tr>
                      <td height="5"></td>
                      <td height="5"></td>
                    </tr>
                    <tr>
                      <td><input type="checkbox" checked="checked" name="priceBid" value="price Bid"  /></td>
                      <td>Price Bid </td>
                    </tr>
                    <tr>
                      <td height="5"></td>
                      <td height="5"></td>
                    </tr>
                    <tr>
                      <td><input type="checkbox" name="warranty" value="warranty"  /></td>
                      <td>Warranty </td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">Due Date </td>
                <td align="left" valign="top"><div id="demo">
                    <input name="dDate" id="datepicker" type="text" class="form" value="" />
                </div></td>
                <td>&nbsp;</td>
                <td align="left" valign="top">Probability </td>
                <td align="left" valign="top"><input name="prob" id="prob" type="text" class="form" placeholder="%"   /></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">Project Name </td>
                <td align="left" valign="top"><input name="projName" type="text" class="form" value="" /></td>
                <td>&nbsp;</td>
                <td>Executive Name </td>
                <td><select name="exeName" id="exeName" class="form" >
                    <option value="">Please Select</option>
                    <%
               List<Executives> le= ( List<Executives>)request.getAttribute("executives");
                if(le!=null){
                	for(int i=0;i<le.size();i++){
                	%>
                    <option value="<%=le.get(i).getExeName()%>"><%=le.get(i).getExeName()%></option>
                    <%}
                }
                %>
                </select></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <%Business bus=(Business)session.getAttribute("business");%>
                <td align="left" valign="top">Company</td>
                <td align="left" valign="top"><input type="text" name="comp" id="comp" class="form"  value="<%=bus.getShortname() %>"/>                </td>
                <td>&nbsp;</td>
                <td>Quote Currency </td>
                <td><select name="quotCurr" class="form" >
                    <option value="">Please Select</option>
                    <option value="<%=Constants.ST_CUR_RUPEE%>">Rs.</option>
                    <option value="<%=Constants.ST_CUR_DOLLAR%>">Dollar</option>
                    <option value="<%=Constants.ST_CUR_EURO%>">Euro</option>
                    <option value="<%=Constants.ST_CUR_SDOLLAR%>">Singapore Dollar</option>
                    <option value="<%=Constants.ST_CUR_YEN%>">Yen</option>
                    <option value="<%=Constants.ST_CUR_POUND%>">Pound</option>
                </select></td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">Opportunity Name </td>
                <td align="left" valign="top"><input name="opprName" type="text" class="form" value="" /></td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
            <td width="2%">&nbsp;</td>
          </tr>
        </table>
      </div>
	  
	  <div class="boxtable">
	 

	    <table width="100%" id="userTable" cellpadding="4" cellspacing="1" bgcolor="#C5E4EB">
          <tr>
            <td width="30" height="30" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"  style="background-repeat:repeat-x"></td>
            <td width="30" height="30" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"  style="background-repeat:repeat-x">S.No</td>
            <td width="90" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF"> Part No </td>
            <td width="135" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF">Description</td>
            <td width="135" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF">Make</td>
            <td width="51" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF"> Quantity </td>
            <td width="144" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF">Specification</td>
            <td width="90" align="left" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-x;bgcolor="#FFFFFF">Application</td>
          </tr>
          <tr>
          	<td align="center" valign="middle" bgcolor="#FFFFFF"><input type="checkbox" name="chkbox"/></td>
            <td bgcolor="#FFFFFF"><input name="sno1" type="text"value="1" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input class="part" name="partno1" type="text" id="partno1" value="" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="desc1" type="text" id="desc1" value=""  autocomplete="off" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input id="make1" autocomplete="off" name="make1" type="text" value="" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="qty1" type="text"value="" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input id="specification1" name="specification1" type="text" value="" size="5" /></td>
           	<td align="left" valign="top" bgcolor="#FFFFFF"><input id="application1" name="application1" type="text" value="" size="5" autocomplete="off" /></td>
          </tr>
          <input type="hidden" id="rowcount" name="rowcount" value="1"/>
        </table>
         
        
        <div class="box3">
        <div class="buttonleft"><a href="javascript: addRow('userTable')" >Add Row</a></div> 
                                   <div class="buttonleft"><a href="javascript: deleteRow('userTable')" >Delete Row</a></div>
                                   <div class="buttonleft"><a href="javascript: AddSelRow('userTable')" >AddSelctedRow</a></div>
                                   
                  
	  </div>
	   <div id="bulletinDialog" style="display: none;">
                  <div id="enqSearchBox"></div>
        </div>
	  <div class="box3">
	    <div class="buttton-main">
	    <input type="submit" class="button" value="Save" onclick="javascript:return processFormData();"/>
	    <input type="reset" class="button" value="Clear"/>	
	    <input type="button" class="button" value="Edit" onclick="javascript: retriveEnq()"/>	
	    <input type="button" class="button" value="Show Stock" onclick="showStock()"/>	
	    </div>
	  </div>
	  
	  </div>
    </div>
    </form>
   <input type="hidden" name="stock" />
    </div>
    <div id="showStockId" title="Stock">
    </div>
    <div id="footer"></div>  
</div>
</body>
</html>
<script  type="text/javascript">
function showStock(){
	 $("#tc").val(1);
	$("#showStockId").dialog('destroy').empty();
	var rowCount=$("#rowcount").val();
	var parts="";
	for(var i=1;i<=rowCount;i++){
		parts+=$("#partno"+i).val()+'<%=Constants.ST_SEPARATOR%>';
		//alert(parts);
	}
	data="parts="+parts;
	//alert(parts);
	$.ajax({
		url:"<%=request.getContextPath()%>/newEnq/showStock.do",
		data:data,
		type:"GET",
		success:function(res){
			 
			$("#showStockId").html(res);
		}
	});
	var $dialog = $('#showStockId').dialog({
        autoOpen: false,
        modal: true,
        width: 790,
        height: 400
      				
    });
		 
    $dialog.dialog('open');
}
function upExcel(){
	var data=$("#excel").val();
	$.ajax({
		url:" <%=application.getContextPath()%>/newEnq/uploadExcel.do",
		enctype: 'multipart/form-data',
		data:"loc="+data,
		success: function(res){
			$("#userTable").html(res);
		}
	});
}
function retriveEnq(){
	
	$.ajax({
		url:" <%=application.getContextPath()%>/jsp/searchEnquiry.jsp",
		mimetype: "text/html",
		cache:false,
		success: function(res){
			
			$("#enqSearchBox").html(res);
			
		}

	});

var $dialog = $('#bulletinDialog').dialog({
                autoOpen: false,
                modal: true,
                width: 790,
                height: 400
              				
            });
 			 
            $dialog.dialog('open');
}


		
    </script>
    <script language="JavaScript" type="text/javascript">
function processFormData(){
	var st=$("#stock").val();
	if(st!=1)alert("Please Check the Stock");
  var frmvalidator  = new Validator("enqForm");
  var rowcount=document.getElementById("rowcount");
  var rowc=rowcount.value;
/*   makeAlert("this is Sample","the rowcount value is"+rowc); */
  for(var i=1;i<=rowc;i++)
	  {
	  var desc=document.getElementById("desc"+i);
	  var part=document.getElementById("partno"+i);
	  var d=desc.value;
	  var p=part.value;
	
	  if(d==""&&d==null){
  frmvalidator.addValidation("partno"+i,"req","Please enter PartNo"+i+"");
/*   frmvalidator.addValidation("partno"+i,"maxlen=30",	"Max length for partno"+i+" is 30");
  frmvalidator.addValidation("partno"+i,"alphanumeric","partno"+i+"Only alpha and Numeric chars only"); */
	  }
  /* frmvalidator.addValidation("make"+i,"req","Please enter made by"+i); */
  /* frmvalidator.addValidation("make"+i,"maxlen=30","Max length of made by"+i+" is 30 "); */
  
  frmvalidator.addValidation("qty"+i,"req","Please enter Required Quantity"+i+" ");
  frmvalidator.addValidation("qty"+i,"numeric","Required Quantity"+i+"  must be numeric");
  

  if(p==""&&p==null){
	  frmvalidator.addValidation("desc"+i,"req","Please enter Description or PartNo"+i+"");
	/*   frmvalidator.addValidation("desc"+i,"maxlen=30",	"Max length for Description"+i+" is 30"); */
	 /*  frmvalidator.addValidation("desc"+i,"alphanumeric","Description"+i+"Only alpha and Numeric chars only"); */
  
 
	  }
}
}
</script>

    